<template>
  <el-dialog
    :visible.sync="open"
    width="1300px"
    @close="handleClose"
    class="dialogClass"
    append-to-body
  >
    <template slot="title">
      <div class="modalTitle">
        <img
          src="@/assets/bluelogo/drawerTitle.png"
          alt=""
          class="titleLogo"
        />批量导入案款发放信息
      </div>
    </template>
    <!-- 新增 -->
    <!-- <div class="pageHeader titlename1">批量导入人员信息</div> -->
    <div class="personAdd" v-for="(item, index) in personList" :key="index">
      <el-row>
        <el-col :span="1">
          <div class="indexClass">{{ index + 1 }}</div></el-col
        >
        <el-col :span="21">
          <el-form
            :model="item"
            :rules="item.personRules"
            :ref="'form' + index"
            size="small"
            label-width="145px"
          >
            <el-row>
              <el-col :span="8"
                ><el-form-item label="案件名称" prop="caseId">
                  <el-select
                    v-model="item.caseId"
                    placeholder="请选择案件名称"
                    @change="caseIdChange($event)"
                    filterable
                    class="caseSelect"
                    ref="select"
                    clearable
                    :disabled="item.isSave"
                  >
                    <el-option
                      v-for="item in caseList"
                      :key="item.id"
                      :label="item.caseName"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select> </el-form-item
              ></el-col>
              <el-col :span="8">
                <el-form-item label="姓名" prop="name">
                  <el-input
                    :disabled="item.isSave"
                    v-model.trim="item.name"
                    placeholder="请输入涉案人姓名"
                    :maxlength="50"
                  ></el-input>
                </el-form-item> </el-col
              ><el-col :span="8">
                <el-form-item label="身份证号" prop="zjh">
                  <el-input
                    v-model.trim="item.zjh"
                    placeholder="请输入涉案人身份证号"
                    :maxlength="50"
                  ></el-input>
                  <!-- <el-select
                    v-model.trim="item.zjh"
                    filterable
                    :disabled="item.isSave"
                    placeholder="请输入身份证号"
                    @change="personZjhChange($event, item, index)"
                    @blur="zjhBlur($event, item)"
                    class="zjhInput"
                  >
                    <el-option
                      v-for="item in zjhList"
                      :key="item.zjh"
                      :label="item.zjh"
                      :value="item.zjh"
                    >
                    </el-option>
                  </el-select> -->
                </el-form-item>
              </el-col>
            </el-row>
            <div v-show="item.showFlag">
              <el-row>
                <el-col :span="12"
                  ><el-form-item label="联系方式" prop="tel">
                    <el-input
                      :disabled="item.isSave"
                      v-model.trim="item.tel"
                      placeholder="请输入涉案人联系方式"
                      :maxlength="50"
                      clearable
                    >
                    </el-input> </el-form-item
                ></el-col>
                <el-col :span="12">
                  <el-form-item label="户籍地址" >
                    <el-input
                      :disabled="item.isSave"
                      v-model.trim="item.residenceAddress"
                      placeholder="请输入涉案人户籍地址"
                      :maxlength="50"
                      clearable
                    >
                    </el-input> </el-form-item
                ></el-col>
              </el-row>
              <el-row>
                <el-form-item label="居住地所属区域" prop="liveAddress">
                  <el-row :gutter="24" class="oucodeList">
                    <el-col :span="7">
                      <el-form-item
                        label-width="0"
                        label=""
                        prop="oucodeList[0]"
                      >
                        <DictionarySelect
                          @change="firstChange($event, item)"
                          class="selectFirst"
                          :disabled="item.isSave"
                          placeholder="请选择省"
                          source="xzqhbm"
                          v-model="item.oucodeList[0]"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item
                        label-width="0"
                        label=""
                        prop="oucodeList[1]"
                      >
                        <DictionarySelect
                          class="selectSecond"
                          :disabled="item.isSave"
                          placeholder="请选择市"
                          :source="item.oucodeList[0]"
                          v-model="item.oucodeList[1]"
                        />
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item
                        label-width="0"
                        label=""
                        prop="oucodeList[2]"
                      >
                        <DictionarySelect
                          class="selectThird"
                          :disabled="item.isSave"
                          placeholder="请选择区县"
                          :source="item.oucodeList[1]"
                          v-model="item.oucodeList[2]"
                        />
                      </el-form-item>
                    </el-col>
                  </el-row>
                </el-form-item>
              </el-row>
              <el-row>
                <el-form-item label="居住地址" prop="liveAddress">
                  <el-input
                    :disabled="item.isSave"
                    v-model.trim="item.liveAddress"
                    placeholder="请输入涉案人居住地址"
                    :maxlength="50"
                    clearable
                  >
                  </el-input>
                </el-form-item>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="发放轮次" prop="payRound">
                    <!-- 发放轮次注掉了 -->
                    <el-select
                      class="selectClass"
                      :disabled="item.isSave"
                      v-model="item.payRound"
                      placeholder="请选择轮次"
                    >
                      <el-option
                        v-for="item in dict.type.pay_round"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="发放时间" prop="payTime">
                    <el-date-picker
                      type="date"
                      class="selectClass"
                      :disabled="item.isSave"
                      value-format="yyyy-MM-dd"
                      placeholder="请选择发放时间"
                      v-model="item.payTime"
                      :picker-options="setDisabled"
                    ></el-date-picker>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item
                    label="判决损失金额(元)"
                    prop="personJudgmentLossAmount"
                  >
                    <el-input
                      oninput="value=value.replace(/[^0-9.]/g,'')"
                      :maxlength="15"
                      :disabled="item.isSave"
                      v-model="item.personJudgmentLossAmount"
                      placeholder="请选择判决损失金额"
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item
                    label="认定发放金额(元)"
                    prop="personConfirmedPaymentAmount"
                  >
                    <el-input
                      :disabled="item.isSave || disabledNeedMoney"
                      oninput="value=value.replace(/[^0-9.]/g,'')"
                      v-model.trim="item.personConfirmedPaymentAmount"
                      placeholder="请输入认定发放金额"
                      :maxlength="15"
                      clearable
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="发放方式" prop="paymentWay">
                    <el-select
                      class="selectClass"
                      :disabled="item.isSave"
                      v-model="item.paymentWay"
                      placeholder="请选择发放方式"
                    >
                      <el-option
                        v-for="item in dict.type.payment_way"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="发放账号" prop="paymentNumber">
                    <el-input
                      :disabled="item.isSave"
                      v-model.trim="item.paymentNumber"
                      placeholder="请输入发放账号"
                      :maxlength="50"
                      clearable
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="发放金额" prop="payMoney">
                    <el-input
                      oninput="value=value.replace(/[^0-9.]/g,'')"
                      :disabled="item.isSave"
                      v-model.trim="item.payMoney"
                      placeholder="请输入发放金额"
                      :maxlength="15"
                      clearable
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </div>
          </el-form>
          <div class="operation">
            <!-- <el-button
              class="searchButton2"
              :icon="item.showFlag == true ? 'el-icon-top' : 'el-icon-bottom'"
              @click="showAll(item)"
              >详情</el-button
            > -->
            <img
              src="../../../assets/images/topArrower.png"
              alt=""
              @click="showAll(item)"
              v-if="item.showFlag == true"
              class="arrow1"
            />
            <img
              src="../../../assets/images/topArrower.png"
              alt=""
              @click="showAll(item)"
              v-else
              class="arrow2 is-active"
            />
          </div>
        </el-col>
        <el-col :span="2">
          <div class="saveDeleteGroup">
            <el-button class="resetButton1" @click="deletePerson(item, index)"
              >删除</el-button
            >
          </div>
        </el-col>
      </el-row>
      <el-divider></el-divider>
    </div>
    <div slot="footer">
      <div class="dialog-footer">
        <el-button class="noButton" @click="handleClose">取消</el-button>
        <el-button
          class="yesButton"
          @click.native="Submit"
          :loading="submitLoading"
          >确定</el-button
        >
      </div>
    </div>
  </el-dialog>
</template>

<script>
import {
  addPayment,
  getPersonInfoByCaseId,
  getWholePersonByZjh,
  judgePayMoney,
} from "@/api/paymentManage/payment";
import { judgmentDup } from "@/api/peopleConfirm/peopleConfirm";
import { getlistCase } from "@/api/paymentManage/payment";
import DictionarySelect from "@/layout/components/dictionnary/DictionarySelect.vue";
export default {
  name: "AddDrawer",
  props: ["importList"],
  dicts: ["pay_round", "payment_way"],
  components: { DictionarySelect },
  inject: ["getList"],
  data() {
    //身份证校验
    // var checkZjh = (rule, value, callback) => {
    //   judgmentDup(value, this.formData.caseId).then((response) => {
    //     if (response === true) {
    //       callback(new Error("该人员尚未进行案款确认，不可录入！"));
    //     } else {
    //       callback();
    //     }
    //   });
    // };
    var zjhNumber = (rule, value, callback) => {
      if (!value) {
        callback(new Error("身份证号不能为空"));
      } else {
        const reg =
          /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/;
        const card = reg.test(value);
        if (!card) {
          callback(new Error("身份证号格式错误！"));
        } else {
          callback();
          //如果有相同证件号的情况下，保存caseId,进行校验
          // let tmpCaseId = "";
          // this.personList.forEach((el) => {
          //   if (el.zjh == value) {
          //     tmpCaseId = el.caseId;
          //   }
          // });
          // let params = {
          //   caseId: tmpCaseId,
          //   zjh: value,
          // };
          // judgmentDup(params.zjh, params.caseId).then((response) => {
          //   console.log(response);
          //   if (response === false) {
          //     callback(new Error("该人员案款确认信息已存在！"));
          //   } else {
          //     callback();
          //   }
          // });
        }
      }
    };
    return {
      // 非多个禁用
      multiple: true, //日期范围限制
      setDisabled: {
        disabledDate(time) {
          return time.getTime() > Date.now(); // 可选历史天、可选当前天、不可选未来天
          // return time.getTime() > Date.now() - 8.64e7;  // 可选历史天、不可选当前天、不可选未来天
          // return time.getTime() < Date.now() - 8.64e7; // 不可选历史天、可选当前天、可选未来天
          // return time.getTime() < Date.now(); // 不可选历史天、不可选当前天、可选未来天
        },
      },
      open: false,
      submitLoading: false,
      personList: [], //人员数组
      //案件管理是否允许选择
      nameFlag: false,
      buttonContent: "保存",
      formData: {
        //案件id
        caseId: "",
        //发放时间
        payTime: "",
        // 发放轮次
        payRound: "",
      },
      dataFlag: false,
      //人员信息的表单校验
      personRules: {
        caseId: [
          {
            required: true,
            message: "请选择案件名称",
            trigger: "change",
          },
        ],
        personConfirmedPaymentAmount: [
          {
            required: true,
            message: "请输入认定发放金额",
            trigger: "blur",
          },
        ],
        personJudgmentLossAmount: [
          {
            required: true,
            message: "请输入判决损失金额",
            trigger: "blur",
          },
        ],
        payMoney: [
          {
            required: true,
            // validator: payMoneyValidate,
            message: "请输入发放金额",
            trigger: "blur",
          },
        ],
        paymentNumber: [
          {
            required: true,
            message: "请输入发放账号",
            trigger: "blur",
          },
        ],
        paymentWay: [
          {
            required: true,
            message: "请选择发放方式",
            trigger: "change",
          },
        ],
        payTime: [
          {
            required: true,
            message: "请输入发放时间",
            trigger: "change",
          },
        ],
        name: [
          {
            required: true,
            message: "请输入发放人员姓名",
            trigger: "blur",
          },
        ],
        // residenceAddress: [
        //   {
        //     required: false,
        //     message: "请输入户籍地址",
        //     trigger: "blur",
        //   },
        // ],
        zjh: [
          {
            required: true,
            validator: zjhNumber,
            // message: "请输入身份证号！",
            trigger: "blur",
          },
        ],
        payRound: [
          {
            required: true,
            // validator: payRoundValidate,
            message: "请输入发放轮次",
            trigger: "change",
          },
        ],
        "oucodeList[0]": [
          {
            required: true,
            message: "请输入省",
            trigger: "change",
          },
        ],
        "oucodeList[1]": [
          {
            required: true,
            message: "请输入市",
            trigger: "change",
          },
        ],
        "oucodeList[2]": [
          {
            required: true,
            message: "请输入县",
            trigger: "change",
          },
        ],
        liveAddress: [
          {
            required: true,
            message: "请输入居住地址",
            trigger: "blur",
          },
        ],
        tel: [
          { required: true, message: "请输入手机号码", trigger: "blur" },
          {
            validator: function (rule, value, callback) {
              if (/^1[34578]\d{9}$/.test(value) == false) {
                callback(new Error("请输入正确的手机号"));
              } else {
                callback();
              }
            },
            trigger: "blur",
          },
        ],
      },
      // 下拉框的数据
      caseList: [],
      sjList: [],
      qxList: [], //区县
      zjhList: [], //新增时人员列表
      //暂存数据
      tem: {},
      disabledNeedMoney: false,
      addFlag: false,
      // 新增页面列表数据
      tableData: [],
      // 新增页面列表id
      listlength: 0,
      // 新增页面的是否可以再加一个列表标志
      isadd: true,
      invaildInfo: "",
      tempZjh: "",
      temNeedMoney: "",
      newSelectValue: "",
      oldSelectValue: "",
    };
  },

  watch: {
    importList: {
      handler(newVal) {
        console.log(newVal);
        if (newVal.length !== 0) {
          this.open = true;
          this.personList = newVal;
          this.getCase();
          console.log(this.personList);
        }
      },
      deep: true,
      immediate: true,
    },
    "formData.caseId": {
      handler(newVal, oldVal) {
        this.newSelectValue = newVal;
        this.oldSelectValue = oldVal;
      },
      deep: true,
      immediate: true,
    },
    "$route.query.id": {
      handler(newVal) {
        if (newVal) {
          this.formData.caseId = newVal;
        }
      },
      immediate: true,
      deep: true,
    },
    // addDrawer: {
    //   handler(newVal) {
    //     if (newVal) {
    //       this.reset();
    //       getlistCase().then((res) => {
    //         this.caseList = res.data;
    //         if (this.$route.query.id) {
    //           this.formData.caseId = Number(this.$route.query.id);
    //           this.getPersonZjhList(this.formData.caseId);
    //           this.nameFlag = true;
    //         }
    //       });
    //     }
    //   },
    //   immediate: true,
    // },
  },
  created() {
    this.getCase();
  },
  methods: {
    //省选择
    firstChange(val, item) {
      console.log(val);
      console.log(item);
      item.formData.oucodeList[1] = "";
      item.formData.oucodeList[2] = "";
    },
    //通过caseId改变去拿身份证号数组
    caseIdChange(val, item) {
      console.log(val, item);
      // if (this.personList.length !== 0) {
      //   this.$modal
      //     .confirm("是否确认切换案件，该操作将清空所有已填数据！")
      //     .then(() => {
      //       this.personList = [];
      //       this.formData.caseId = this.newSelectValue;
      //       this.$modal.msgSuccess("删除成功");
      //       this.$refs.select.blur();
      //     })
      //     .catch(() => {
      //       this.formData.caseId = this.oldSelectValue;
      //       this.$refs.select.blur();
      //     });
      // }
      // this.getPersonZjhList(val);
    },
    //通过zjh改变获得对应formdata
    personZjhChange(val, item, index) {
      //改变选择后将选择的值给当前item的zjh的值
      item.zjh = val;
      if (val) {
        //如果这个值存在通过zjh和caseId获取这个在这个案件下这个zjh的所有信息返显
        getWholePersonByZjh(val, item.caseId).then((response) => {
          if (response.data) {
            item.name = response.data.name;
            item.residenceAddress = response.data.residenceAddress;
            item.oucodeList = response.data.oucodeList;
            item.liveAddress = response.data.liveAddress;
            item.tel = response.data.tel;
            item.personJudgmentLossAmount =
              response.data.personJudgmentLossAmount;
            item.personConfirmedPaymentAmount =
              response.data.personConfirmedPaymentAmount;
          }
        });
      } else {
        //如果zjh空
        this.personList[index] = {
          isSave: false, //是否禁用
          showFlag: true, //是否完全展示
          buttonContent: "保存",
          personRules: this.personRules,
          name: "", //姓名
          zjh: "", //证件号
          residenceAddress: "", //户籍地址
          liveAddress: "",
          tel: "",
          payRound: "",
          payTime: "", //发放事件
          sheng: "", //省
          shi: "", //市
          quxian: "", //区县
          paymentWay: "", //罚款方式
          paymentNumber: "", //发放账号
          needMoney: "", //应发金额
          payMoney: "", //发放金额
          personJudgmentLossAmount: "", //判决损失金额
          personConfirmedPaymentAmount: "", //个人认定发放金额
          oucodeList: ["省", "市", "区县"],
        };
      }
    },
    //通过caseId获取人员列表
    getPersonZjhList(val) {
      getPersonInfoByCaseId(val).then((response) => {
        this.zjhList = response.data;
      });
    },
    //丢失焦点后将输入的值给这个item的zjh
    zjhBlur(e, item) {
      item.zjh = e.target.value;
    },
    // 表单重置
    reset() {
      this.personList = [];
      this.resetForm("form");
    },

    //关闭抽屉
    handleClose(done) {
      this.submitLoading = false;
      this.resetForm("form");
      // this.tableData.splice(0, this.tableData.length);
      this.$emit("update:personList", []);
      this.open = false;
    },
    /**
     * 通过oucode获取案件下拉菜单
     */
    getCase() {
      let queryParm = {
        oucode: this.$store.state.user.oucode,
      };
      getlistCase(queryParm).then((response) => {
        this.caseList = response.data;
      });
    },
    /**提交表单，如果有一条信息没有保存或者未填写案款发放人员信息将无法保存，
     * 如果每一项中disabledFlag为false,表单没有禁用，submitFlag++，
     * 最后submitFlag==0并且表单长度不为0的时候才能提交
     */
    Submit() {
      let peopleList = [];
      let submitFlag = false;
      this.personList.forEach((el, index) => {
        let form = "form" + index;
        this.$refs[form][0].validate((valid) => {
          if (valid) {
            peopleList.push(el);
          } else {
            el.showFlag = true;
            submitFlag = true;
            return;
          }
        });
      });
      if (submitFlag) {
        this.$modal.msgWarning("表单中存在未完成信息，请确认后重新输入！");
      } else {
        let TPaymentDTO = {
          caseId: this.formData.caseId,
          peopleList: peopleList,
        };
        addPayment(TPaymentDTO)
          .then(() => {
            this.submitLoading = false;
            this.$modal.msgSuccess("新增成功");
            this.getList();
            this.open = false;
            this.resetForm("form");
            // this.tableData.splice(0, this.tableData.length);
            this.$emit("update:personList", []);
          })
          .catch(() => {});
      }
      // let submitFlag = false;
      // console.log(this.personList);
      // this.personList.forEach((el) => {
      //   if (el.buttonContent == "保存") {
      //     submitFlag = true;
      //   }
      // });
      // if (submitFlag == true) {
      //   this.$message.warning("当前表单存在未保存确认信息，请确认后再提交！");
      // } else {
      //   this.submitLoading = true;
      //   let peopleList = [];
      //   this.personList.forEach((el) => {
      //     peopleList.push(el);
      //   });
      //   let TPaymentDTO = {
      //     // caseId: this.formData.caseId,
      //     peopleList: peopleList,
      //   };
      //   //发请求
      //   addPayment(TPaymentDTO)
      //     .then(() => {
      //       this.submitLoading = false;
      //       this.$modal.msgSuccess("新增成功");
      //       this.open = false;
      //       this.$emit("getList");
      //       this.resetForm("form");
      //       // this.tableData.splice(0, this.tableData.length);
      //       this.$emit("update:personList", []);
      //     })
      //     .catch(() => {});
      // }
    },
    //通过每一个表单在循环中的index进行删除
    deletePerson(item, index) {
      let number = index;
      this.personList.forEach((element, index) => {
        if (index == number) {
          this.personList.splice(number, 1);
        }
      });
    },
    //展开，隐藏
    showAll(item) {
      item.showFlag = !item.showFlag;
    },
    //点击新增，如果未选案件，要先选案件,通过flag去判断personlist里是不是只有一个未保存的，如果有未保存，那无法继续新增
    // addPerson() {
    //   let person = {
    //     personRules: this.personRules,
    //     disabledFlag: false, //是否禁用
    //     showFlag: true, //是否完全展示
    //     buttonContent: "保存",
    //     formData: {
    //       name: "", //姓名
    //       zjh: "", //证件号
    //       residenceAddress: "", //户籍地址
    //       liveAddress: "",
    //       residenceAddress: "",
    //       tel: "",
    //       payRound: "",
    //       payTime: "", //发放事件
    //       sheng: "", //省
    //       shi: "", //市
    //       quxian: "", //区县
    //       paymentWay: "", //罚款方式
    //       paymentNumber: "", //发放账号
    //       needMoney: "", //应发金额
    //       payMoney: "", //发放金额
    //       personJudgmentLossAmount: "", //判决损失金额
    //       personConfirmedPaymentAmount: "", //个人认定发放金额
    //       oucodeList: ["省", "市", "区县"],
    //     },
    //   };
    //   if (!this.formData.caseId) {
    //     this.$modal.msgWarning("请先选择所属案件！");
    //   } else {
    //     this.personList.push(person);
    //   }
    // },
    //每个表单保存按钮，首先填写身份证，通过所选身份证验证表单是否通过校验，没通过校验无法保存，通过校验保存
    save(item, index) {
      let form = "form" + index;
      //动态添加发放轮次校验规则
      const payRoundValidate = (rule, value, callback) => {
        //判断是否有重复案件下的重复的人,如果存在同身份证同案件的情况，计算表单中所有的金额总额去校验
        if (!value) {
          callback(new Error("请输入发放轮次"));
        } else {
          let [...list] = this.personList;
          console.log(list);
          list.splice(index, 1);
          let payRoundFlag = false;
          list.forEach((el) => {
            if (item.zjh == el.zjh && item.payRound == el.payRound) {
              payRoundFlag = true;
            }
          });
          if (payRoundFlag) {
            callback(
              new Error(
                "该人员在此表单中已经录入相同轮次发放信息，请确认后重新输入！"
              )
            );
          } else {
            callback();
          }
        }
      };
      const payRoundnewRule = [
        item.personRules.payRound,
        {
          validator: payRoundValidate,
          trigger: "blur",
          required: true,
        },
      ];
      item.personRules = Object.assign({}, item.personRules, {
        payRound: payRoundnewRule,
      });
      // console.log(this.rules);
      // 动态添加发放金额校验规则;
      const payMoneyValidate = (rule, value, callback) => {
        //判断是否有重复案件下的重复的人,如果存在同身份证同案件的情况，计算表单中所有的金额总额去校验
        if (!value) {
          callback(new Error("发放为空，请确认输入"));
        } else {
          let payMoneySum = 0;
          this.personList.forEach((el) => {
            console.log(el);
            if (el.zjh == item.zjh) {
              payMoneySum = payMoneySum * 1 + el.payMoney * 1;
            }
          });
          judgePayMoney(payMoneySum, item.zjh, item.caseId).then((response) => {
            if (response.flag === false) {
              callback(
                new Error(
                  "发放金额大于应发放金额,本次发放剩余应发放金额为" +
                    response.remainAmount +
                    "元！"
                )
              );
            } else {
              callback();
            }
          });
        }
      };
      const payMoneynewRule = [
        item.personRules.payMoney,
        {
          validator: payMoneyValidate,
          required: true,
          trigger: "blur",
        },
      ];
      item.personRules = Object.assign({}, item.personRules, {
        payMoney: payMoneynewRule,
      });
      // console.log(this.rules);
      setTimeout(() => {
        this.$refs[form][0].validate((valid) => {
          if (valid) {
            if (item.buttonContent == "保存") {
              item.buttonContent = "编辑";
              item.isSave = true;
              item.showFlag = false;
            } else {
              item.buttonContent = "保存";
              item.isSave = false;
              item.showFlag = true;
            }
          } else {
            return;
          }
        });
      }, 200);
    },
  },
};
</script>

<style lang="scss" scoped>
@import "../../../assets/styles/dialog.scss"; //模态框样式
@import "../../../assets/styles/drawer.scss";
@import "../../../assets/styles/variables.scss";
// @import "../../../assets/styles/list.scss";
// @import "./addDrawer.scss";
.iconClass {
  color: #4f7ff8;
  font-size: 30px;
  position: absolute;
  top: 8px;
  margin-left: 10px;
}
::v-deep.el-form-item .el-form-item__error {
  width: 85px !important;
}
.personDialogClass {
  ::v-deep .el-dialog__body {
    padding: 10px 30px 10px 30px !important;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 650px !important;
    max-height: 700px;
  }
  ::v-deep.el-dialog:not(.is-fullscreen) {
    margin-top: 3vh !important;
  }
}
.noButton {
  border: 0.1rem solid #598af9;
  height: 3.8rem;
  width: 81px;
  border-radius: 0.2rem;
  margin-right: 1rem;
  font-size: 1.6rem;
  font-family: Microsoft YaHei;
  font-weight: bold;
  letter-spacing: 0;
  color: #598af9;
  line-height: 1rem;
  letter-spacing: 0px;
  background: white;
}
.yesButton {
  width: 81px;
  border: 0px;
  height: 39px;
  background: $form-button-background-color;
  border-radius: 3px;
  font-size: $form-button-font-size;
  margin-right: 10px;
  font-family: $font-family;
  font-weight: $form-button-font-weight;
  letter-spacing: 0;
  color: #fefbfb;
  line-height: 10px;
  letter-spacing: 2px;
}
.addButton {
  width: 81px;
  border: 0px;
  height: 39px;
  background: $form-button-background-color;
  border-radius: 3px;
  font-size: $form-button-font-size;
  margin-right: 10px;
  font-family: $font-family;
  font-weight: $form-button-font-weight;
  letter-spacing: 0;
  color: #fefbfb;
  line-height: 10px;
  letter-spacing: 2px;
}
.trueButton {
  width: 120px;
  border: 0px;
  height: 39px;
  background: $form-button-background-color;
  border-radius: 3px;
  font-size: $form-button-font-size;
  margin-right: 10px;
  font-family: $font-family;
  font-weight: $form-button-font-weight;
  letter-spacing: 0;
  color: #fefbfb;
  line-height: 10px;
  letter-spacing: 2px;
}
.delButton {
  border: 0.1rem solid #598af9;
  height: 38px;
  width: 120px;
  border-radius: 3px;
  margin-right: 10px;
  font-size: $form-button-font-size;
  font-family: $font-family;
  font-weight: $form-button-font-weight;
  letter-spacing: 0;
  color: #598af9;
  line-height: 10px;
  letter-spacing: 2px;
  background: white;
}
.indexClass {
  margin-top: 17px;
  margin-left: 30px;
  width: 18px;
  height: 18px;
  text-align: center;
  line-height: 18px;
  border: 1px solid #2a92ed;
  border-radius: 4px;
  color: #2a92ed;
  font-size: 14px;
  font-family: DengXian;
  font-weight: 400;
}
.personAdd {
  margin-top: 15px;
  .operationButton {
    display: flex;
    width: 100%;
    height: 50px;
    justify-content: space-between;
    vertical-align: middle;
  }
}
::v-deep.el-form-item {
  margin-top: 15px !important;
  margin-bottom: 15px !important;
}
.operation {
  padding-top: 5px;
  width: 100%;
  display: flex;
}
.caseSelect {
  width: 300px !important;
}
.selectClass {
  width: 100% !important;
}
.addressSelect {
  margin-right: 20px !important;
}
.saveDeleteGroup {
  display: flex;
  margin-left: 50px;
}
// .personDialogClass {
//   ::v-deep.el-dialog__body {
//     padding-right: 25px !important;
//   }
// }
::v-deep.el-form-item .el-form-item__error {
  width: 100% !important;
}
.arrow1 {
  width: 35px;
  height: 30px;
  position: absolute;
  bottom: -8px;
  left: 50%;
  cursor: pointer;
}
.arrow2 {
  width: 35px;
  height: 30px;
  position: absolute;
  bottom: -23px;
  left: 50%;
  cursor: pointer;
}
.is-active {
  transform: rotate(180deg);
}
.border {
  width: 1145px;
  height: 1px;
  margin-top: 3px;
  background-color: #d1d1d1;
}
.searchButton1 {
  margin-top: 15px;
  width: 60px;
  height: 30px;
  background: #598af9;
  border-radius: 4px;
  font-weight: 700;
  margin-right: 10px;
  font-family: Microsoft YaHei;
  letter-spacing: 2px;
  color: #fefbfb;
  border: 0px;
}
.searchButton2 {
  margin-left: 500px;
  width: 60px;
  height: 30px;
  font-size: 14px;
  background: #598af9;
  border-radius: 4px;
  margin-right: 10px;
  font-weight: 700;
  font-family: Microsoft YaHei;
  letter-spacing: 2px;
  color: #fefbfb;
  border: 0px;
}
.zjhInput {
  width: 240px;
}
.resetButton1 {
  margin-top: 15px;
  border: 1px solid #598af9;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 700;
  width: 60px;
  height: 30px;
  background: #fff;
  font-family: Microsoft YaHei;
  color: #598af9;
  letter-spacing: 2px;
}
.oucodeList {
  ::v-deep .el-form-item {
    margin: 0 !important;
  }
}
.dialogClass {
  ::v-deep .el-dialog {
    top: 50px;
    left: 40px;
  }
}
//省
.selectFirst {
  width: 300px !important;
  margin-left: -13px !important;
}
//市
.selectSecond {
  width: 300px !important;
  margin-left: 30px !important;
}
//区县
.selectThird {
  width: 295px !important;
  margin-left: 30px !important;
}
</style>>